package org.come.baitan;

import com.tool.Document.RichDocument;
import com.tool.Stall.Commodity;
import com.tool.Stall.Stall;
import com.tool.Stall.StallBean;
import com.tool.Stall.StallBuy;
import com.tool.btn.MoBanBtn;
import com.tool.image.ImageMixDeal;
import com.tool.role.RoleData;
import come.tool.Fighting.FightingMixDeal;
import org.come.Frame.TradeJframe;
import org.come.Frame.ZhuFrame;
import org.come.bean.LoginResult;
import org.come.bean.RoleShow;
import org.come.entity.Goodstable;
import org.come.entity.RoleSummoning;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.*;

import javax.swing.*;
import javax.swing.text.BadLocationException;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;

/**
 * @author 式
 * @version 1.0
 * @project test1
 * @description 摆摊按钮
 * @date 2024/1/28 13:09:05
 */
public class BaiTanBtn extends MoBanBtn {
    ImageIcon imageIcon = new ImageIcon("inkImg/btsg/上方按钮-选中.png");
    ImageIcon imageIcon1 = new ImageIcon("inkImg/btsg/上方按钮-未选中.png");
    int cao;
    BaiTanJpanel baiTanJpanel;
    GouMaiJpanel gouMaiJpanel;

    public BaiTanBtn(String path, int type, Font font, Color[] colors, String txt, BaiTanJpanel baiTanJpanel, int cao) {
        super(path, type, colors);
        this.setText(txt);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.baiTanJpanel = baiTanJpanel;
        this.cao = cao;

    }

    public BaiTanBtn(String path, int type, int cao, BaiTanJpanel baiTanJpanel) {
        super(path, type);
        this.baiTanJpanel = baiTanJpanel;
        this.cao = cao;

    }

    public BaiTanBtn(String path, int type, Font font, Color[] colors, String txt, GouMaiJpanel baiTanJpanel, int cao) {
        super(path, type, colors);
        this.setText(txt);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.gouMaiJpanel = baiTanJpanel;
        this.cao = cao;

    }

    @Override
    public void chooseyes() {

    }

    @Override
    public void chooseno() {

    }

    @Override
    public void nochoose(MouseEvent p0) {
        if (baiTanJpanel != null) {
            baiTanJpanel.xuanzhong(null, 0);
        }
        switch (cao) {
            case 0:
                //  BtnUtil.btnBinding((MoBanBtn[])baiTanJpanel.xuanxiangka, cao);
                if (baiTanJpanel.goodstable != null) {
                    baiTanJpanel.xuanzhong(baiTanJpanel.goodstable, baiTanJpanel.c);
                }
                try {
                    baiTanJpanel.xuanxiangka[0].setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/出售-1.png"));
                    baiTanJpanel.xuanxiangka[1].setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/收购-3.png"));
                    baiTanJpanel.xuanxiangka[2].setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/交易记录-5.png"));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                baiTanJpanel.id = cao;
                baiTanJpanel.setPice(true);
                baiTanJpanel.shoushoubtn.setVisible(false);
                baiTanJpanel.baitan.setVisible(true);
                break;
            case 1:
                //  BtnUtil.btnBinding((MoBanBtn[])baiTanJpanel.xuanxiangka, cao);
                try {
                    baiTanJpanel.xuanxiangka[0].setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/出售-2.png"));
                    baiTanJpanel.xuanxiangka[1].setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/收购-4.png"));
                    baiTanJpanel.xuanxiangka[2].setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/交易记录-5.png"));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                baiTanJpanel.id = cao;
                baiTanJpanel.setPice(true);
                baiTanJpanel.shoushoubtn.setVisible(true);
                baiTanJpanel.baitan.setVisible(false);
                break;
            case 2:
                //  BtnUtil.btnBinding((MoBanBtn[])baiTanJpanel.xuanxiangka, cao);

                try {
                    baiTanJpanel.xuanxiangka[0].setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/出售-2.png"));
                    baiTanJpanel.xuanxiangka[1].setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/收购-3.png"));
                    baiTanJpanel.xuanxiangka[2].setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/交易记录-6.png"));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                baiTanJpanel.id = cao;
                baiTanJpanel.setPice(false);
                baiTanJpanel.shoushoubtn.setVisible(false);
                baiTanJpanel.baitan.setVisible(false);
                if (baiTanJpanel.Stall.getRoleid() == null) {
                    ZhuFrame.getZhuJpanel().addPrompt("请先开始摆摊！");
                    return;
                }
                ;
                final String sendMes1 = Agreement.BaiTanmessge(GsonUtilsb.getGsonUtil().getgson().toJson(baiTanJpanel.Stall));
                SendMessageUntil.toServer(sendMes1);
                break;
	 /* case 3:
	  case 4:
	  case 5:
	  case 6:
	  case 7:
	  case 8:
		  BtnUtil.btnBinding((MoBanBtn[])baiTanJpanel.pack, cao-3);
		  baiTanJpanel.packid=cao-3;
	  	break;*/
            case 10:
                if (baiTanJpanel == null) {
                    return;
                }
                if (baiTanJpanel.baitan.getText().equals("收摊")) {
                    ZhuFrame.getZhuJpanel().addPrompt("正在摆摊，请收摊后在操作");
                    return;
                }
                if (baiTanJpanel.goodstable != null && baiTanJpanel.petxz == null) {

                    if (baiTanJpanel.shangjia.getText().equals("上架")) {
                        if (baiTanJpanel.goodstable.getQuality() % 2 != 0) {
                            ZhuFrame.getZhuJpanel().addPrompt("禁止交易物品无法上架！");
                            return;
                        }
                        ShouGou shouGou = new ShouGou();
                        shouGou.pice = baiTanJpanel.danjia;
                        shouGou.num = baiTanJpanel.nub;
                        baiTanJpanel.goodstableList.put(baiTanJpanel.goodstable, shouGou);
                    } else {
                        baiTanJpanel.goodstableList.remove(baiTanJpanel.goodstable);
                    }
                } else if (baiTanJpanel.petxz != null) {
                    if (baiTanJpanel.shangjia.getText().equals("上架")) {
                        if (baiTanJpanel.goodstable.getQuality() % 2 != 0) {
                            ZhuFrame.getZhuJpanel().addPrompt("禁止交易召唤兽无法上架！");
                            return;
                        }
                        if (baiTanJpanel.petrolesulist.size() >= 6) {
                            ZhuFrame.getZhuJpanel().addPrompt("最多上架6个宠物");
                            return;
                        }
                        ShouGou shouGou = new ShouGou();
                        shouGou.pice = baiTanJpanel.danjia;
                        shouGou.num = 1;
                        baiTanJpanel.petrolesulist.put(baiTanJpanel.petxz, shouGou);
                        int i = 0;
                        for (RoleSummoning roleSummoning : baiTanJpanel.petrolesulist.keySet()) {
                            {
                                final ImageIcon img = new ImageIcon("img/newHead/p" + roleSummoning.getSummoningskin() + ".png");
                                img.setImage(img.getImage().getScaledInstance(50, 50, 10));
                                baiTanJpanel.PetsListLabel[i].setBounds(56 + 57 * i, 310, 50, 50);
                                baiTanJpanel.PetsListLabel[i].setIcon(img);
                                final ImageIcon path1 = CutButtonImage.getImage("inkimg/danxin/ss291.png", 45, 45);
                                path1.setImage(path1.getImage().getScaledInstance(45, 45, 10));
                                baiTanJpanel.PetsListLabeldi[i].setIcon(path1);
                                i++;
                            }
                        }
                        for (; i < 6; i++) {
                            {
                                baiTanJpanel.PetsListLabel[i].setIcon(null);
                                baiTanJpanel.PetsListLabeldi[i].setIcon(null);
                            }
                        }
                    } else {
                        baiTanJpanel.petrolesulist.remove(baiTanJpanel.petxz);
                        int i = 0;
                        for (RoleSummoning roleSummoning : baiTanJpanel.petrolesulist.keySet()) {
                            {
                                final ImageIcon img = new ImageIcon("img/newHead/p" + roleSummoning.getSummoningskin() + ".png");
                                img.setImage(img.getImage().getScaledInstance(50, 50, 10));
                                baiTanJpanel.PetsListLabel[i].setBounds(56 + 57 * i, 310, 50, 50);
                                baiTanJpanel.PetsListLabel[i].setIcon(img);
                                final ImageIcon path1 = CutButtonImage.getImage("inkimg/danxin/ss291.png", 45, 45);
                                path1.setImage(path1.getImage().getScaledInstance(45, 45, 10));
                                baiTanJpanel.PetsListLabeldi[i].setIcon(path1);
                                i++;
                            }
                        }
                        for (; i < 6; i++) {
                            {
                                baiTanJpanel.PetsListLabel[i].setIcon(null);
                                baiTanJpanel.PetsListLabeldi[i].setIcon(null);
                            }
                        }

                    }

                }
                break;
            case 11:
                try {
                    baiTanJpanel.lingbao.setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/灵宝-9.png"));
                    baiTanJpanel.pet.setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/宠物-8.png"));
                    TradeJframe.getTradejframe().getTradejpanel().getModelname().removeAllElements();
                    if (UserMessUntil.getPetListTable() != null) {
                        for (int i = 0; i < UserMessUntil.getPetListTable().size(); i++) {
                            TradeJframe.getTradejframe().getTradejpanel().getModelname()
                                    .add(i, UserMessUntil.getPetListTable().get(i).getSummoningname());
                        }
                    }
                    BaiTanJframe.getBaiTanJframe().getBaiTanJpanel().setLocation(20, 70);
                    FormsManagement.showForm(15);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            case 12:
                try {
                    baiTanJpanel.lingbao.setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/灵宝-10.png"));
                    baiTanJpanel.pet.setIcons(CutButtonImage.cuts("skin/8100226/rg-bt/宠物-7.png"));
                    FormsManagement.HideForm(15);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            case 13:
                if (baiTanJpanel == null) {
                    return;
                }
                if (baiTanJpanel.baitan.getText().equals("收摊")) {
                    ZhuFrame.getZhuJpanel().addPrompt("正在摆摊，请收摊后在操作");
                    return;
                }
                if (baiTanJpanel.shoushoubtn.getText().equals("收购")) {
                    if (baiTanJpanel.pice.getText() == null || baiTanJpanel.pice.getText().equals("")) return;
                    if (baiTanJpanel.shuliang.getText() == null || baiTanJpanel.shuliang.getText().equals("")) return;
                    if (baiTanJpanel.nub * baiTanJpanel.danjia == 0) return;
                    Goodstable goodstable = UserMessUntil.getgoodstablefromname(baiTanJpanel.modelname.get(baiTanJpanel.index));
                    if (goodstable == null) return;
                    if (baiTanJpanel.shougou.containsKey(goodstable)) return;
                    ShouGou shouGou = new ShouGou();
                    shouGou.pice = baiTanJpanel.danjia;
                    shouGou.num = baiTanJpanel.nub;
                    shouGou.goodstable = goodstable;
                    baiTanJpanel.shougou.put(goodstable, shouGou);
                } else {
                    Goodstable goodstable = UserMessUntil.getgoodstablefromname(baiTanJpanel.modelname.get(baiTanJpanel.index));
                    if (goodstable != null) {
                        baiTanJpanel.shougou.remove(goodstable);
                        baiTanJpanel.modelname.remove(baiTanJpanel.index);
                        if (baiTanJpanel.index == 0) {
                            baiTanJpanel.index = -1;
                        }
                    }


                }

                break;
            case 14:
                if (baiTanJpanel.baitan.getText().equals("摆摊")) {
                    final RoleShow roleShow = ImageMixDeal.userimg.getRoleShow();
                    if (roleShow.getMapid() != 1236L) {
                        ZhuFrame.getZhuJpanel().addPrompt("只能在洛阳集市摆摊");
                        return;
                    }
                    if (roleShow.getX() < 5977 || roleShow.getX() > 8290) {
                        ZhuFrame.getZhuJpanel().addPrompt("只能在洛阳集市摆摊");
                        return;
                    }
                    if (roleShow.getY() < 3099 || roleShow.getY() > 4174) {
                        ZhuFrame.getZhuJpanel().addPrompt("只能在洛阳集市摆摊");
                        return;
                    }
                    if (roleShow.getTroop_id() != null || FormsManagement.getframe(14).isVisible() || FightingMixDeal.State != 0) {
                        ZhuFrame.getZhuJpanel().addPrompt2("当前状态不能摆摊！");
                    }
                    Stall stall = baiTanJpanel.getStall();
                    if (stall.getId() > 0) {
                        ZhuFrame.getZhuJpanel().addPrompt2("你已经在摆摊了");
                        return;
                    }
                    if (roleShow.getGrade().intValue() <= 69) {
                        ZhuFrame.getZhuJpanel().addPrompt2("70级之后才可以摆摊");
                        return;
                    }
                    if (roleShow.getMount_id() != 0) {
                        ZhuFrame.getZhuJpanel().addPrompt2("在摆摊了还要骑着坐骑干什么");
                        return;
                    }
                    for (Goodstable goodstable : baiTanJpanel.shougou.keySet()) {
                        stall.getShouGous().add(baiTanJpanel.shougou.get(goodstable));
                    }
                    Commodity[] good = new Commodity[24];
                    int i = 0;
                    for (Goodstable goodstable : baiTanJpanel.goodstableList.keySet()) {
                        Commodity commodity = new Commodity();
                        commodity.setGood(goodstable);
                        commodity.setMoney(baiTanJpanel.goodstableList.get(goodstable).pice);
                        commodity.setNumber(baiTanJpanel.goodstableList.get(goodstable).num);
                        good[i] = commodity;
                        i++;

                    }
                    stall.setGoodstables(good);
                    Commodity[] pet = new Commodity[6];
                    i = 0;
                    for (RoleSummoning pet1 : baiTanJpanel.petrolesulist.keySet()) {
                        Commodity commodity = new Commodity();
                        commodity.setPet(pet1);
                        commodity.setMoney(baiTanJpanel.petrolesulist.get(pet1).pice);
                        commodity.setNumber(1);
                        pet[i] = commodity;
                        i++;
                    }
                    stall.setPets(pet);
                    stall.setMapid(Util.ditubianma);
                    stall.setRoleid(roleShow.getRole_id());
                    stall.setRole(roleShow.getRolename());
                    stall.setStall(roleShow.getRolename() + "的摊位");
                    stall.setState(StallBean.PREPARE);
                    stall.setId(1);
                    stall.setX(roleShow.getX() - 50);
                    stall.setY(roleShow.getY() - 135);

                    final String sendMes = Agreement.getAgreement().stallAgreement(GsonUtil.getGsonUtil().getgson().toJson(stall));
                    SendMessageUntil.toServer(sendMes);
                    baiTanJpanel.baitan.setText("收摊");
                    ZhuFrame.getZhuJpanel().addPrompt("开始摆摊！某些功能将被限制");
                    FormsManagement.HideForm(15);
                    FormsManagement.HideForm(16);
                } else if (baiTanJpanel.baitan.getText().equals("收摊")) {
                    final RoleShow roleShow = ImageMixDeal.userimg.getRoleShow();
                    Stall stall = baiTanJpanel.getStall();
                    stall.setMapid(Util.ditubianma);
                    stall.setRoleid(roleShow.getRole_id());
                    stall.setRole(roleShow.getRolename());
                    stall.setStall(roleShow.getRolename() + "的摊位");
                    // stall.setId(0);
                    stall.setState(StallBean.NO);
                    final String sendMes = Agreement.getAgreement().stallAgreement(GsonUtil.getGsonUtil().getgson().toJson(stall));
                    SendMessageUntil.toServer(sendMes);
                    baiTanJpanel.baitan.setText("摆摊");
                }
                break;
            case 100:
                if (gouMaiJpanel.goumai.getText().equals("购买")) {
                    StallBuy stallBuy = new StallBuy();
                    stallBuy.setId(gouMaiJpanel.stall.getId());
                    stallBuy.setRoleid(RoleData.getRoleData().getLoginResult().getRole_id());
                    BigDecimal money = RoleData.getRoleData().getLoginResult().getGold();
                    long itemPrice = gouMaiJpanel.good.getMoney();
                    long maxQuantity = gouMaiJpanel.good.getNumber();
                    int quantityToBuy = Integer.parseInt(gouMaiJpanel.shuliang.getText());

                    // 计算买家可以购买的最大数量
                    int affordableQuantity = money.divide(new BigDecimal(itemPrice), 0, BigDecimal.ROUND_DOWN).intValue();

                    if (affordableQuantity == 0) {
                        ZhuFrame.getZhuJpanel().addPrompt2("大话币不足");
                        return;
                    }

                    // 如果买家想要购买的数量超过可以购买的最大数量，则提示买家可以购买的最大数量
                    if (quantityToBuy > affordableQuantity) {
                        ZhuFrame.getZhuJpanel().addPrompt2("大话币不足，最多可购买 " + affordableQuantity + " 件");
                        return;
                    }

                    // 设置实际购买数量
                    stallBuy.setSum(quantityToBuy);

                    if (gouMaiJpanel.petandgood == 1) {
                        stallBuy.setType(0);
                        if (gouMaiJpanel.good.getGood().getRgid() == null) return;
                        stallBuy.setBuyid(gouMaiJpanel.good.getGood().getRgid());
                    } else if (gouMaiJpanel.petandgood == 2) {
                        stallBuy.setType(1);
                        if (gouMaiJpanel.good.getPet().getSid() == null) return;
                        stallBuy.setBuyid(gouMaiJpanel.good.getPet().getSid());
                    } else return;

                    final String sendMes2 = Agreement.getAgreement().stallbuyAgreement(GsonUtil.getGsonUtil().getgson().toJson(stallBuy));
                    SendMessageUntil.toServer(sendMes2);
                } else if (gouMaiJpanel.goumai.getText().equals("出售")) {
                    StallBuy stallBuy = new StallBuy();
                    stallBuy.setId(gouMaiJpanel.stall.getId());
                    stallBuy.setRoleid(RoleData.getRoleData().getLoginResult().getRole_id());
                    stallBuy.setType(3);
                    Goodstable goodstable = GouMaiJpanel.getGoodType(gouMaiJpanel.shougou.goodstable.getGoodsid().longValue());
                    if (goodstable == null) return;
                    //  goodstable.setUsetime(goodstable.getUsetime()-Integer.parseInt(gouMaiJpanel.shuliang.getText()));
                    stallBuy.setBuyid(goodstable.getRgid());
                    stallBuy.setSum(Integer.parseInt(gouMaiJpanel.shuliang.getText()));
                    final String sendMes2 = Agreement.getAgreement().stallbuyAgreement(GsonUtil.getGsonUtil().getgson().toJson(stallBuy));
                    SendMessageUntil.toServer(sendMes2);
                }


                break;
            case 101:
                try {
                    gouMaiJpanel.xuanxiangka[0].setIcons(CutButtonImage.cuts("inkImg/btsg/上方按钮-选中.png"));
                    gouMaiJpanel.xuanxiangka[1].setIcons(CutButtonImage.cuts("inkImg/btsg/上方按钮-未选中.png"));
                    gouMaiJpanel.xuanxiangka[2].setIcons(CutButtonImage.cuts("inkImg/btsg/上方按钮-未选中.png"));
                    gouMaiJpanel.updateLabels(gouMaiJpanel.stall, 0, 1, true);
                    gouMaiJpanel.shuliang.setVisible(true);
                    gouMaiJpanel.goumai.setVisible(true);
                    gouMaiJpanel.goumai.setText("购买");
                    gouMaiJpanel.goodandpet[0].setVisible(true);
                    gouMaiJpanel.goodandpet[1].setVisible(true);
                    gouMaiJpanel.petandgood = 1;
                    gouMaiJpanel.good = null;
                    for (int i = 0; i <= gouMaiJpanel.myJpanels.size() - 1; i++) {
                        gouMaiJpanel.myJpanels.get(i).setVisible(false);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }

                break;
            case 102:
                try {
                    gouMaiJpanel.xuanxiangka[0].setIcons(CutButtonImage.cuts("inkImg/btsg/上方按钮-未选中.png"));
                    gouMaiJpanel.xuanxiangka[1].setIcons(CutButtonImage.cuts("inkImg/btsg/上方按钮-选中.png"));
                    gouMaiJpanel.xuanxiangka[2].setIcons(CutButtonImage.cuts("inkImg/btsg/上方按钮-未选中.png"));
                    gouMaiJpanel.updateLabels(gouMaiJpanel.stall, 1, -1, true);
                    gouMaiJpanel.shuliang.setVisible(true);
                    gouMaiJpanel.goumai.setVisible(true);
                    gouMaiJpanel.goumai.setText("出售");
                    gouMaiJpanel.goodandpet[0].setVisible(false);
                    gouMaiJpanel.goodandpet[1].setVisible(false);
                    gouMaiJpanel.petandgood = -1;
                    gouMaiJpanel.good = null;
                    for (int i = 0; i <= gouMaiJpanel.myJpanels.size() - 1; i++) {
                        gouMaiJpanel.myJpanels.get(i).setVisible(true);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }

                break;
            case 103:
                try {
                    gouMaiJpanel.xuanxiangka[0].setIcons(CutButtonImage.cuts("inkImg/btsg/上方按钮-未选中.png"));
                    gouMaiJpanel.xuanxiangka[1].setIcons(CutButtonImage.cuts("inkImg/btsg/上方按钮-未选中.png"));
                    gouMaiJpanel.xuanxiangka[2].setIcons(CutButtonImage.cuts("inkImg/btsg/上方按钮-选中.png"));
                    gouMaiJpanel.updateLabels(gouMaiJpanel.stall, 2, -1, true);
                    gouMaiJpanel.shuliang.setVisible(false);
                    gouMaiJpanel.goumai.setVisible(false);
                    gouMaiJpanel.goodandpet[0].setVisible(false);
                    gouMaiJpanel.goodandpet[1].setVisible(false);
                    gouMaiJpanel.petandgood = -1;
                    gouMaiJpanel.good = null;
                    for (int i = 0; i <= gouMaiJpanel.myJpanels.size() - 1; i++) {
                        gouMaiJpanel.myJpanels.get(i).setVisible(false);
                    }

                    if (gouMaiJpanel.stall.getRoleid() == null) {
                        ZhuFrame.getZhuJpanel().addPrompt("请先开始摆摊！");
                        return;
                    }
                    ;
                    final String sendMes2 = Agreement.BaiTanmessge(GsonUtilsb.getGsonUtil().getgson().toJson(gouMaiJpanel.stall));
                    SendMessageUntil.toServer(sendMes2);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            case 104:
                try {
                    gouMaiJpanel.goodandpet[0].setIcons(CutButtonImage.cuts("inkImg/btsg/售卖类别按钮-选中.png"));
                    gouMaiJpanel.goodandpet[1].setIcons(CutButtonImage.cuts("inkImg/btsg/售卖类别按钮-未选中.png"));
                    gouMaiJpanel.petandgood = 1;
                    gouMaiJpanel.updateLabels(gouMaiJpanel.stall, 0, 1, true);
                    gouMaiJpanel.good = null;
                } catch (Exception e) {
                    e.printStackTrace();
                }

                break;
            case 105:
                try {
                    gouMaiJpanel.goodandpet[0].setIcons(CutButtonImage.cuts("inkImg/btsg/售卖类别按钮-未选中.png"));
                    gouMaiJpanel.goodandpet[1].setIcons(CutButtonImage.cuts("inkImg/btsg/售卖类别按钮-选中.png"));
                    gouMaiJpanel.petandgood = 2;
                    gouMaiJpanel.updateLabels(gouMaiJpanel.stall, 0, 2, true);
                    gouMaiJpanel.good = null;
                } catch (Exception e) {
                    e.printStackTrace();
                }

                break;
            case 106:
                if (baiTanJpanel.baitan.getText().equals("摆摊")) {
                    ZhuFrame.getZhuJpanel().addPrompt("请先开始摆摊");
                    return;
                }
                JTextField SendMes = ZhuFrame.getZhuJpanel().getSendMes();
                try {
                    ((RichDocument) SendMes.getDocument()).insertRich(SendMes.getCaretPosition(), 100,
                            new BigDecimal(baiTanJpanel.Stall.getId()), "[" + baiTanJpanel.getStall().getStall() + "]", "G", null);
                } catch (BadLocationException e) {
                    e.printStackTrace();
                }
                break;
            case 107:
                if (baiTanJpanel != null) {
                    if (baiTanJpanel.baitan.getText().equals("摆摊")) {
                        ZhuFrame.getZhuJpanel().addPrompt("请先开始摆摊");
                        return;
                    }
                    String stallName = baiTanJpanel.getStallName();
                    if (stallName.length() > 7) {
                        ZhuFrame.getZhuJpanel().addPrompt2("#最大7个字符");
                        return;
                    }

                    LoginResult roleData = RoleData.getRoleData().getLoginResult();
                    Stall stall = BaiTanJpanel.copyStall(roleData);
                    stall.setStall(stallName);
                    final String sendMes = Agreement.getAgreement().updatestallAgreement(GsonUtil.getGsonUtil().getgson().toJson(stall));
                    SendMessageUntil.toServer(sendMes);
                }
        }
    }
}
